package com.ywl.myInterface;

import com.ywl.entity.Author;
import com.ywl.utlis.AuthorFactory;

import java.util.List;
import java.util.function.Predicate;

/**
 * @author 24040
 * @name InterfaceDemo01
 * @date 2022-08-23 18:47
 */
public class InterfaceDemo01 {
    public static void main(String[] args) {
        test01();
    }

    /**
     * 打印作家中年龄大于17并且姓名的长度大于1的作家。
     */
    private static void test01() {
        List<Author> authors = AuthorFactory.getAuthors();
        authors.stream()
                .filter(author -> author.getAge()>17 && author.getName().length() > 1)
                .forEach(author -> System.out.println(author.getName()));
        /*authors.stream()
                .filter(((Predicate<Author>) author -> author.getAge() > 17)
                        .and(author -> author.getName().length()>1))
                .forEach(author -> System.out.println(author.getName()));*/
    }
}
